package com.qzimp.fujiancuo;

import com.mybatisflex.codegen.Generator;
import com.mybatisflex.codegen.config.GlobalConfig;
import com.zaxxer.hikari.HikariDataSource;

public class MyBatisFlexCodeGenerator {
    public static void main(String[] args) {
        HikariDataSource dataSource = new HikariDataSource();

        dataSource.setJdbcUrl("jdbc:mysql://localhost:3306/mycuo?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8");
        dataSource.setUsername("root");
        dataSource.setPassword("");

        GlobalConfig globalConfig=createGlobalConfigStyle();

        Generator generator=new Generator(dataSource,globalConfig);


        generator.generate();


    }


    public static GlobalConfig createGlobalConfigStyle(){

        GlobalConfig globalConfig=new GlobalConfig();

        globalConfig.setAuthor("吴宗波");

        globalConfig.setBasePackage("com.qzimp.fujiancuo");
        globalConfig.setTablePrefix("tb_");

        globalConfig.setGenerateTable(
                "tb_admin",
                "tb_admin_log",
                "tb_album",
                "tb_architecture",
                "tb_cuisine",
                "tb_cuisine_category",
                "tb_cuo",
                "tb_enterprise",
                "tb_event",
                "tb_image_category",
                "tb_legend",
                "tb_personage",
                "tb_region",
                "tb_tourist",
                "tb_userinfo",
                "tb_userinfo_log"
        );

        //设置生成entity 启用lombok
        globalConfig.setEntityGenerateEnable(true);

        globalConfig.setEntityWithLombok(true);

        globalConfig.setEntityWithSwagger(true);
        globalConfig.setMapperGenerateEnable(true);



        globalConfig.setServiceGenerateEnable(true);
        globalConfig.setServiceImplGenerateEnable(true);


        globalConfig.setControllerGenerateEnable(true);


//        globalConfig.setTableDefGenerateEnable(true);


        globalConfig.setMapperXmlGenerateEnable(true);



        return  globalConfig;

    }
}


